package com.jl.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jl.pojo.SysCallLog;
import com.jl.service.SysCallLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * @author : ljl
 * @date : 16:59 2020/12/30
 */
@Slf4j
@Controller
@RequestMapping("/call")
public class SysCallLogController {

    @Autowired
    private SysCallLogService sysCallLogService;

    /**
     * 查询所有通话记录
     * @return
     */
    @ResponseBody
    @GetMapping("/list")
    public List<SysCallLog> list() {
        log.info("==========list");
        return sysCallLogService.list();
    }
    @GetMapping("/index")
    public String index() {
        log.info("==========index");
        return "index";
    }
    @GetMapping("/index2")
    public String index2() {
        log.info("==========index2");
        return "index2";
    }
    @GetMapping("/demo")
    public String demo() {
        log.info("==========demo");
        return "demo";
    }

    public static void main(String[] args) {
        String result = "{\n" +
                "\t\"empty\": false,\n" +
                "\t\"primaryPrincipal\": {\n" +
                "\t\t\"admin\": true,\n" +
                "\t\t\"avatar\": \"/profile/avatar/2021/02/04/2d7e4cbd-9565-4f79-a59b-567377840776.png\",\n" +
                "\t\t\"createTime\": 1606099639000,\n" +
                "\t\t\"delFlag\": \"0\",\n" +
                "\t\t\"dept\": {\n" +
                "\t\t\t\"params\": {}\n" +
                "\t\t},\n" +
                "\t\t\"loginDate\": 1621503270326,\n" +
                "\t\t\"loginIp\": \"127.0.0.1\",\n" +
                "\t\t\"loginName\": \"admin\",\n" +
                "\t\t\"params\": {},\n" +
                "\t\t\"password\": \"be1afa2ad3116cf5297b859213fb5bbf\",\n" +
                "\t\t\"roles\": [{\n" +
                "\t\t\t\"admin\": false,\n" +
                "\t\t\t\"dataScope\": \"1\",\n" +
                "\t\t\t\"flag\": false,\n" +
                "\t\t\t\"params\": {},\n" +
                "\t\t\t\"roleId\": 104,\n" +
                "\t\t\t\"roleKey\": \"sos\",\n" +
                "\t\t\t\"roleName\": \"应急中心管理员\",\n" +
                "\t\t\t\"roleSort\": \"5\",\n" +
                "\t\t\t\"status\": \"0\"\n" +
                "\t\t}],\n" +
                "\t\t\"salt\": \"daa0d1\",\n" +
                "\t\t\"status\": \"0\",\n" +
                "\t\t\"userId\": 1,\n" +
                "\t\t\"userName\": \"admin\"\n" +
                "\t},\n" +
                "\t\"realmNames\": [\"com.cgjd.framework.shiro.realm.UserRealm_0\"]\n" +
                "}";

//        private boolean empty;
//        private PrimaryPrincipal primaryPrincipal;
//        private List<String> realmNames;

        Object o1 = JSON.toJSON(result);

        JSONObject o = (JSONObject) JSONObject.toJSON(result);


        System.out.println("===");

    }
}
